

<template tag="以下文档内容为hycli自动生成">
  <el-dialog
    v-model="conf.visible"
    v-if="conf.visible" 
    :title="title"
    :width="conf.width"
    draggable
    align-center="true"
    :close-on-click-modal="false"
  >
<el-form :model="form"  ref="form" :rules="rules_aaayr">
    <el-row>
    <el-col :span="12">
    <!-- {"index":7,"raw":"name","name":"name","cname":"Name","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["c","u","l","le","q","v","DN","#like"],"desc":{"raw":"名称","name":"名称"}} -->
    <!--名称 输入控件 -->
    <el-form-item prop="name" label="名称" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.name"  maxlength="32" 
      :rows="0"  placeholder="请输入名称"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":8,"raw":"dpt_id","name":"dpt_id","cname":"DptId","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":true,"constraints":["c","u","l","q","le","fq","sl(department_info)","tp(tree,l)","v","lw(160)","tp(cascader,c-u-w)","color","w"],"desc":{"raw":"部门","name":"部门"}} -->
     <!--部门 选择树 -->
     <el-form-item  label="部门" label-width="100px" label-position="right">
        <el-cascader ref="cascader_aaayi" style="width: 100%;"
        v-model="form.dpt_id" 
        placeholder="请选择部门"
        collapse-tags  collapse-tags-tooltip  clearable   :options="dpt_idList"
        :props="{  children: 'children', label: 'name' }" />
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":9,"raw":"lob_id","name":"lob_id","cname":"LobId","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["tp(ddmenu,q)","tp(multicheck,c-u)","c","u","l","q(#lob_id)","fq","le","sl(my_business_line)","v","lw(200)","color","w","ps(full)","DG"],"desc":{"raw":"业务线","name":"业务线"}} -->
    <!--业务线 chckbox-group -->
    <el-form-item prop="lob_id" label="业务线" label-width="100px" label-position="right">
      <el-checkbox-group v-model="form.lob_id"  >
      <el-checkbox-button v-for="item in lob_idList" :key="item.value" :label="item.value"  :value="item.value">
        {{item.name}}
        </el-checkbox-button>
      </el-checkbox-group>
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":10,"raw":"position","name":"position","cname":"Position","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["c","u","l","q","fq","le","sl","v","DT","color"],"desc":{"raw":"岗位","name":"岗位"}} -->
     <!--岗位 下拉控件 -->
    <el-form-item prop="position" label="岗位" label-width="100px" label-position="right">
      <el-select   v-model="form.position" style="width: 100%" filterable clearable
        placeholder="请选择岗位" >
        <el-option v-for="item in positionList" :key="item.value" :label="item.name" :value="item.value" />
      </el-select>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":11,"raw":"title","name":"title","cname":"Title","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["c","u","l","le","sl","q","DP","fq","v","tp(multiselect)","color"],"desc":{"raw":"职位","name":"职位"}} -->
    <!--职位 多选控件 --> 
    <el-form-item prop="title" label="职位" label-width="100px" label-position="right">
      <el-select style="width: 100%"   v-model="form.title" clearable multiple  collapse-tags 
      collapse-tags-tooltip
        placeholder="请选择职位">
        <el-option v-for="item in titleList" :key="item.value" :label="item.name" :value="item.value" />
      </el-select>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":12,"raw":"mobile","name":"mobile","cname":"Mobile","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["c","u","l","le","v"],"desc":{"raw":"手机","name":"手机"}} -->
    <!--手机 输入控件 -->
    <el-form-item prop="mobile" label="手机" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.mobile"  maxlength="32" 
      :rows="0"  placeholder="请输入手机"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":13,"raw":"email","name":"email","cname":"Email","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["c","u","le","v"],"desc":{"raw":"邮箱","name":"邮箱"}} -->
    <!--邮箱 输入控件 -->
    <el-form-item prop="email" label="邮箱" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.email"  maxlength="32" 
      :rows="0"  placeholder="请输入邮箱"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":14,"raw":"is_email_enabled","name":"is_email_enabled","cname":"IsEmailEnabled","type":{"raw":"number(2)","name":"number","len":2,"dlen":0},"defValue":"1","allowNull":false,"constraints":["c","u","q","le","v","q","tp(switch,l)","sl(bool)","tp(radio)"],"desc":{"raw":"邮件通知","name":"邮件通知"}} -->
    <el-form-item prop="is_email_enabled" label="邮件通知" label-width="100px" label-position="right">
      <el-radio-group v-model="form.is_email_enabled"   >
        <el-radio-button v-for="item in is_email_enabledList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":15,"raw":"status","name":"status","cname":"Status","type":{"raw":"number(2)","name":"number","len":2,"dlen":0},"defValue":"","allowNull":false,"constraints":["c","u","l","le","v","sl","color","q","tp(switch,l)","fq","tp(radio)","DS","rp","tp(tabs,q,staff_status)"],"desc":{"raw":"状态","name":"状态"}} -->
    <el-form-item prop="status" label="状态" label-width="100px" label-position="right">
      <el-radio-group v-model="form.status"   >
        <el-radio-button v-for="item in statusList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    </el-row>
</el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="hide" icon="close">取消</el-button>
        <el-button type="primary" @click="save" icon="select">提交</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import rtext from "@/views/cmpnts/rtext.vue"
export default {
  components: {
    rtext
},
  data() {
    return {
      conf: {
        visible: false,
        width:"60%",
        uploadPath:this.$theia.env.join("/file/upload"),
      },
      title:"修改员工信息",
rules_aaayr:{
    name:[{required:true,message:"请输入名称",trigger: 'blur'}],
    dpt_id:[{required:false,message:"请输入部门",trigger: 'blur'}],
    lob_id:[{required:true,message:"请输入业务线",trigger: 'blur'}],
    position:[{required:true,message:"请输入岗位",trigger: 'blur'}],
    title:[{required:true,message:"请输入职位",trigger: 'blur'}],
    mobile:[{required:true,message:"请输入手机",trigger: 'blur'}],
    email:[{required:true,message:"请输入邮箱",trigger: 'blur'}],
    is_email_enabled:[{required:true,message:"请输入邮件通知",trigger: 'blur'}],
    status:[{required:true,message:"请输入状态",trigger: 'blur'}],
  },
    form:{
        name:"",
        dpt_id:"",
        lob_id:[],
        position:"",
        title:[],
        mobile:"",
        email:"",
        is_email_enabled:"",
        status:"",
    },
    dpt_idList:[],
    lob_idList:[],
    positionList:[],
    titleList:[],
    is_email_enabledList:[],
    statusList:[],
    }
  },
  methods: {
    show(form) {
      this.conf.visible = true;
      this.loadEnums_aaayr()
      this.form = Object.assign(form,this.$route.params)
      this.get(form)
    },
      get(form){
        let that = this
        this.conf.loading = true
        let postForm = {}
        postForm.staff_id = form.staff_id
        this.$theia.http.get("/ws/staff/info",postForm).then(res=>{
          res.lob_id = (res.lob_id+"").split(",")
          res.title = (res.title+"").split(",")
          that.form = Object.assign(that.form, res)
          that.form.dpt_id = that.form.dpt_id
        //处理枚举重新绑定
          this.loadEnums_aaayr()
          that.conf.loading = false
        }).catch(res=>{
          let code = ((res||{}).response||{}).status||0
          let msg = `员工信息查询失败(${code})`
          that.$notify.error({title: '失败',message:msg ,duration:5000})
        })
    },
    save(){
        this.$refs.form.validate((v=>{
            if(v) this.onSave()
        }))
    },
    onSave(){
      let that = this
        let postForm = Object.assign({},this.form)
        let dpt_id = []
        let dpt_idNodes = this.$refs.cascader_aaayi.getCheckedNodes() || []
        dpt_idNodes.forEach(v => {
          dpt_id.push(v.value)
        })
        postForm.dpt_id = dpt_id.join(",")
        postForm.lob_id = (postForm.lob_id||[]).join(",")
        postForm.title = (postForm.title||[]).join(",")
        this.$theia.http.put("/ws/staff/info",postForm).then(res=>{
            that.$notify.success({title: '成功',message: '员工信息保存成功',duration:5000})
            that.$theia.enum.clear("staff_info")
            that.$theia.enum.get("staff_info")
            that.hide()
            that.$emit("onsaved")
        }).catch(res=>{
            let code = ((res||{}).response||{}).status||0
            let msg = `员工信息修改失败(${code})`
            that.$notify.error({title: '失败',message: msg,duration:5000})
        })
    },
    hide() {
      this.conf.visible = false;
      this.$refs.form.resetFields();
    },
     onUploadSuccess(response){
    },
    loadEnums_aaayr(){
        //部门
        this.dpt_idList = this.$theia.enum.getTree("department_info","","" ,99)
        //业务线
        this.lob_idList = this.$theia.enum.get("my_business_line","","" ,false,"")
        //岗位
        this.positionList = this.$theia.enum.get("position","","" ,false,"")
        //职位
        this.titleList = this.$theia.enum.get("title","","" ,false,"")
        //邮件通知
        this.is_email_enabledList = this.$theia.enum.get("bool","","" ,false,"")
        //状态
        this.statusList = this.$theia.enum.get("status","","" ,false,"")
    },

  },
};
</script>

<style scoped>
.form_item_info{
  margin-left: 4px;
  color:#999;
}
.form_item_info:hover{
  cursor: pointer;
  font-weight: 500;
  color:#333;
}
</style>